//
//  EFReturnListViewCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/5/13.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFReturnListViewCell.h"
#import "EFReturnListViewItem.h"

@interface EFReturnListViewCell()

@property(strong,nonatomic)UILabel* headerView;
@property(strong,nonatomic)UILabel* dateLabel;
@property(strong,nonatomic)UIImageView* moreIV;
@property(strong,nonatomic)UIView* lineView;
@property(strong,nonatomic)UILabel* reasonLabel;
@property(strong,nonatomic)UILabel* resultLabel;

@end

@implementation EFReturnListViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor = [UIColor whiteColor];
        [self initView];
    }
    return self;
}

-(void)setObject:(EFReturnListViewItem *)item{
    [self.dateLabel setText:item.requestTime];
    [self.dateLabel sizeToFit];
    
    NSMutableAttributedString * strReason = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"退货原因： %@",item.reason]];

    NSRange range = NSMakeRange(0, 5);
    [strReason addAttribute:NSForegroundColorAttributeName value:kBlack999 range:range];
    [self.reasonLabel setAttributedText:strReason];
    
    
    NSMutableAttributedString * strResult = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"处理结果： %@",item.statusName]];
    
    NSRange range2 = NSMakeRange(0, 5);
    [strResult addAttribute:NSForegroundColorAttributeName value:kBlack999 range:range2];
    [self.resultLabel setAttributedText:strResult];
    
}

-(void)initView{
    [self.contentView addSubview:self.headerView];
    [self.contentView addSubview:self.dateLabel];
    [self.contentView addSubview:self.moreIV];
    [self.contentView addSubview:self.lineView];
    [self.contentView addSubview:self.reasonLabel];
    [self.contentView addSubview:self.resultLabel];

}

-(void)layoutSubviews{
    self.headerView.top = 0;
    
    self.dateLabel.left = 20;
    self.dateLabel.top = self.headerView.bottom +  24;
    
    self.moreIV.top =  self.headerView.bottom + 13;
    self.moreIV.left = kScreenWidth - 20 -20;
    
    self.lineView.left = 20;
    self.lineView.top = self.dateLabel.bottom + 11;
    
    self.reasonLabel.left = 20;
    self.reasonLabel.top = self.lineView.bottom + 11;
    
    self.resultLabel.left = 20;
    self.resultLabel.top = self.reasonLabel.bottom + 6;
    
}

-(UIView*)headerView{
    if(_headerView == NULL){
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth  , 10)];
        _headerView.backgroundColor = RGBCOLOR(0xF4F4F4);
    }
    return _headerView;
}

-(UILabel *)dateLabel{
    if(_dateLabel == NULL){
        _dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 100, 12)];
        _dateLabel.font = [UIFont systemFontOfSize:13];
        _dateLabel.textColor = kBlack999;
    }
    return _dateLabel;
}

-(UIImageView *)moreIV{
    if(_moreIV == NULL){
        _moreIV = [[UIImageView alloc ] initWithFrame:CGRectMake(0, 0, 20, 20)];
        [_moreIV setImage:IMG(@"more_icon_me_default")];
        
    }
    return _moreIV;
}

-(UIView *)lineView{
    if(_lineView == NULL){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 1)];
        _lineView.backgroundColor = RGBCOLOR(0xECECEC);
    }
    return _lineView;
}


-(UILabel *)reasonLabel{
    if(_reasonLabel == NULL){
        _reasonLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 18)];
        _reasonLabel.font = [UIFont systemFontOfSize:13];
        _reasonLabel.textColor = kBlack333;
    }
    return _reasonLabel;
}


-(UILabel *)resultLabel{
    if(_resultLabel == NULL){
        _resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 18)];
        _resultLabel.font = [UIFont systemFontOfSize:13];
        _resultLabel.textColor = kBlack333;
    }
    return _resultLabel;
}



@end
